{extend name="public/base" /}

{block name="title"}<title>{if condition="$data"}{$Think.lang.edit}{else /}{$Think.lang.create}{/if}</title>{/block}

{block name="pjax_container"}
<section class="content-header">
    <h1>配置信息</h1>
    <ol class="breadcrumb">
        <li class="active"><i class="fa fa-dashboard"></i> 配置信息</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <form class="form-horizontal" method="POST" action="{:url('Config/save')}" onsubmit="return false" >
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab1" data-toggle="tab">{$Think.lang.base_param}</a></li>
                        <li class=""><a href="#tab2" data-toggle="tab">本地音乐</a></li>
                        <li class="">{:BTN('Music/create','','添加音乐')}</li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab1">
                            <input type="hidden" name="type" value="{$type}" />
                            {volist name="data" id="vo"}
                            {if condition="$vo.texttype eq 'textarea'"} 	<!--文本(多行)-->
	                            <div class="form-group">
	                                <label class="col-sm-2 control-label">{$vo.desc}</label>
	                                <div class="col-sm-7">
	                                	<textarea class="form-control" name="{$vo.k}" placeholder="{$vo.prompt}">{$vo.v}</textarea>
	                                </div>
	                                <div class="col-sm-2 h5">变量名：<span class="text-danger">{$vo.k}</span></div>
	                            </div>
                            {elseif condition="$vo.texttype eq 'select'"/} 	<!--列表-->
	                            <div class="form-group">
	                                <label class="col-sm-2 control-label">{$vo.desc}</label>
	                                <div class="col-sm-7">
	                                    <select class="form-control " name="{$vo.k}" style="width:100%;">
	                                    	{volist name="vo['textvalue']" id="vv"}
	                                        	<option value="{$key}"{if condition="$vo.v eq $key"} selected="selected" {/if} >{$vv}</option>
	                                        {/volist}
	                                    </select>
	                                </div>
	                                <div class="col-sm-2 h5">变量名：<span class="text-danger">{$vo.k}</span></div>
	                            </div>
                            {elseif condition="$vo.texttype eq 'image' "/} 	<!--图片-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">{$vo.desc}</label>
                                <div class="col-sm-7">
                                    <div class="input-group">
                                        <input class="form-control" name="{$vo.k}" value="{$vo.v}" placeholder="{$vo.prompt}" >
                                        <span class="input-group-btn">
                                            <a href="{$vo.v|default='/static/global/face/no-image.png'}" target="_blank" >
                                                <img src="{$vo.v|default='/static/global/face/no-image.png'}" style="height:34px; width:68px;" />
                                            </a>
                                            <button class="btn btn-success btn-flat up-btn" type="button" data-url="{:url('Uploads/upload')}?dir={$vo.texttype}">
                                                <i class="fa fa-cloud-upload"> {$Think.lang.Upload}</i>
                                            </button>
                                        </span>
                                        <!--<span class="input-group-btn"><a class="btn btn-info btn-flat"><i class="fa fa-picture-o"> 查看图片</i></a></span>-->
                                    </div>
                                </div>
	                            <div class="col-sm-2 h5">变量名：<span class="text-danger">{$vo.k}</span></div>
                            </div>
                            {else /} 	<!--文本(单行)-->
		                        <div class="form-group">
		                            <label class="col-sm-2 control-label">{$vo.desc}</label>
		                            <div class="col-sm-7">
		                            	<input class="form-control" name="{$vo.k}" value="{$vo.v}" placeholder="{$vo.prompt}">
		                            </div>
	                                <div class="col-sm-2 h5">变量名：<span class="text-danger">{$vo.k}</span></div>
		                        </div>
                            {/if}
                            {/volist}
                        </div>
                        <div class="tab-pane " id="tab2">

				            <div class="box box-primary">
				                <div class="box-body table-responsive">
				                    <table class="table table-bordered table-hover table-sort">
				                        <tr>
				                            <th>{$Think.lang.id}</th>
				                            <th>音乐歌名</th>
				                            <th>歌手名称</th>
				                            <th width="250">音乐地址</th>
				                            <th width="250">封面地址</th>
				                            <th>是否启用</th>
				                            <th>排序</th>
				                            <th width="124">{$Think.lang.action}</th>
				                        </tr>
				                        {volist name="musicList" id="vo"}
				                        <tr>
				                            <td>{$vo.id}</td>
				                            <td>
				                            	<span class="editable" data-pk="{$vo.id}" data-name="name" data-value="{$vo.name}" data-url="{:url('Music/edit', 'id='.$vo['id'])}" >
				                            		{$vo.name}
				                            	</span>
				                            </td>
				                            <td>
				                            	<span class="editable" data-pk="{$vo.id}" data-name="author" data-value="{$vo.author}" data-url="{:url('Music/edit', 'id='.$vo['id'])}" >
				                            		{$vo.author}
				                            	</span>
				                            </td>
				                            <td>
				                            	<span class="editable" data-pk="{$vo.id}" data-name="src" data-value="{$vo.src}" data-url="{:url('Music/edit', 'id='.$vo['id'])}" >
				                            		{$vo.src}
				                            	</span>
				                            </td>
				                            <td>
				                            	<span class="editable" data-pk="{$vo.id}" data-name="cover" data-value="{$vo.cover}" data-url="{:url('Music/edit', 'id='.$vo['id'])}" >
				                            		{$vo.cover}
				                            	</span>
				                            </td>
				                            <td>
				                                <a href="javascript:void(0);" data-id="{$vo.id}" data-field="status"
				                                data-value="{$vo.status}" data-url="{:url('Music/edit', 'id='.$vo['id'])}"
				                                class='editimg fa {if condition=" $vo.status == 1 "}fa-check-circle text-green{else /}fa-times-circle text-red{/if}'></a>
				                            <td>
				                            	<span class="editable" data-pk="{$vo.id}" data-name="orderby" data-value="{$vo.orderby}" data-url="{:url('Music/edit', 'id='.$vo['id'])}" >
				                            		{$vo.orderby}
				                            	</span>
				                            </td>
				                            </td>
				                            <td>
				                            	{:BTN('Music/edit','id='.$vo["id"],'编辑','btn btn-primary btn-xs','fa fa-edit')}
				                            	{:BTN('Music/delete','id='.$vo["id"],'删除','btn btn-danger btn-xs delete-one','fa fa-trash','data-id="'.$vo["id"].'" data-url="/admin/Music/delete"')}

				                            </td>
				                        </tr>
				                        {/volist}
				                    </table>
				                </div>
				                <div class="box-footer clearfix">
				                    {$musicList->render()}
				                </div>
				            </div>




                        </div>
                    </div>
                    <div class="box-footer">
                        <div class="col-sm-2"></div>
                        <div class="col-sm-7">
                            <div class="btn-group pull-right">
                                {:authAction(C_NAME.'/save', 'save')}
                            </div>
                            <div class="btn-group pull-left">
                                <button type="reset" class="btn btn-warning">{$Think.lang.reset}</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>
<script type="text/javascript">
$(function(){
    $('.editable').editable({
        emptytext: "empty",
        params: function(params) {      //参数
            var data = {};
            data['id'] = params.pk;
            data[params.name] = params.value;
            return data;
        },
        success: function(response, newValue) {
            var res = $.parseJSON( response );
            if(res.status == 1){
            }else{
                return res.info;
            }
        }
    });

    /*ajax页面加载icheck，有该控件的页面才需要*/
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });

    /*ajax页面加载icheck，有该控件的页面才需要*/
    $(".select2").select2({language:"zh-CN"});

    {if condition=" $rest_login == 1 "}
    	restlogin('{$rest_login_info}');   //登录超时
    {/if}
})
</script>
{/block}